๐Ÿ“ฆ gopikrishna000 / templates-latest

๐Ÿ“„ modified dfs tree to array.cpp ยท 34 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34<snippet>
	<content><![CDATA[

int timer=0 , n;
vector<int> start,endx , brr ,c; 
vector<vector<int>> arr;
 
void dfs(int root,int par){
    // cerr<<root<<"x ";
    start[root] = timer;
    timer++;
    brr.push_back(c[root]);
 
    for(auto &x:arr[root]){
        if(x!=par){
            //   cerr<<x<<"y ";
            dfs(x,root);
        }
    }
 
    endx[root] = timer;
    timer++;
    brr.push_back(c[root]);
}



]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>modified dfs tree to array</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.c++</scope>
</snippet>